
***************************************************************
*************** GENDER AND CONFLICT ***************************
***************************************************************
clear
use "Basedata.dta"

xtset country_id time

***LABELING
label variable v2x_gender "FPE"
label variable v2x_gender "Historical FPE"
label variable v2x_gencl "Womens civil liberties"
label variable v2x_gencs "Womens civil society participation"
label variable v2x_genpp "Womens political participation"
label variable v2x_polyarchy "Democracy"
label variable v2x_polyarchy_sq "Democracy$^{2}$"
label variable e_migdppcln "GDP pc."
label variable lnpop "Population"
label variable v2lgfemleg  "Female legislators"
label variable  v2mefemjrn  "Female journalists"
label variable v2cldmovew  "Freedom of movement"
label variable  v2clslavef  "Freedom from forced labor"
label variable v2csgender  "Womens CSO participation"
label variable v2clprptyw  "Womens property rights"
label variable  v2clacjstw   "Womens access to justice"
label variable   v2cldiscw   "Freedom of discussion"
label variable   v2pepwrgen   "Power distributed by gender"
label variable s_far_Maddison_gdppc_1990_estim "GDP p.c."
label variable s_far_Maddison_pop_estimate "L(population)"


****DESCRIPTIVES
estpost summarize v2x_gender hist_v2x_gender conflict_onset v2x_gencl v2x_gencs v2x_genpp v2x_polyarchy v2lgfemleg v2mefemjrn v2cldmovew v2clslavef v2csgender v2clprptyw v2clacjstw v2cldiscw v2pepwrgen s_far_Maddison_gdppc_1990_estim s_far_Maddison_pop_estimate 

esttab, cells("count mean sd min max") noobs


****************************************************************************************************************************************************

                                                                 *TABLE 1 

****************************************************************************************************************************************************


set more off

**HISTORICAL 

*gender index - year fe
logit F.conflict_onset hist_v2x_gender  peaceyears peaceyears2 peaceyears3 i.year i.region_best, cluster(country_id)
estimates store m1 

*gender index - year + country fe
xtlogit F.conflict_onset hist_v2x_gender  peaceyears peaceyears2 peaceyears3 i.year , fe
estimates store m2 

*gender index - controls, year fe
logit F.conflict_onset hist_v2x_gender s_far_Maddison_gdppc_1990_estim s_far_Maddison_pop_estimate v2x_polyarchy v2x_polyarchy_sq peaceyears peaceyears2 peaceyears3 i.year i.region_best , cluster(country_id)
estimates store m3 

*gender index - controls, year + country fe
xtlogit F.conflict_onset hist_v2x_gender s_far_Maddison_gdppc_1990_estim s_far_Maddison_pop_estimate v2x_polyarchy v2x_polyarchy_sq peaceyears peaceyears2 peaceyears3 i.year , fe
estimates store m4

*gender index - controls, year + country re
xtlogit F.conflict_onset hist_v2x_gender s_far_Maddison_gdppc_1990_estim s_far_Maddison_pop_estimate v2x_polyarchy v2x_polyarchy_sq peaceyears peaceyears2 peaceyears3 i.year , re
estimates store m5

**CONTEMPORARY
*gender index - year + region fe
logit F.conflict_onset v2x_gender s_far_Maddison_gdppc_1990_estim s_far_Maddison_pop_estimate v2x_polyarchy v2x_polyarchy_sq peaceyears peaceyears2 peaceyears3 i.year i.region_best , cluster(country_id)
estimates store m6 

*gender index - year + country fe
xtlogit F.conflict_onset v2x_gender s_far_Maddison_gdppc_1990_estim s_far_Maddison_pop_estimate v2x_polyarchy v2x_polyarchy_sq peaceyears peaceyears2 peaceyears3 i.year , fe
estimates store m7

**ONLY UCDP
*gender index - year fe
logit F.conflict_onset v2x_gender s_far_Maddison_gdppc_1990_estim s_far_Maddison_pop_estimate v2x_polyarchy v2x_polyarchy_sq peaceyears peaceyears2 peaceyears3 i.year i.region_best if year >1945 , cluster(country_id)
estimates store m8 

*gender index - year + country fe
xtlogit F.conflict_onset v2x_gender s_far_Maddison_gdppc_1990_estim s_far_Maddison_pop_estimate v2x_polyarchy v2x_polyarchy_sq peaceyears peaceyears2 peaceyears3 i.year if year >1945 , fe
estimates store m9

esttab m1 m2 m3 m4 m4b m5 m6 m7 m8 using "  " , replace  style(tex) nogaps compress mtitles label stats(N countryFE regionFE roundFE districtFE homelandFE)
 
 
****************************************************************************************************************************************************
                                                               **TABLE 2 - SUBCOMPONENTS
****************************************************************************************************************************************************

**TABLE 2 - SUBCOMPONENTS 
label variable v2lgfemleg  "Female legislators"
label variable  v2mefemjrn  "Female journalists"
label variable v2cldmovew  "Freedom of movement"
label variable  v2clslavef  "Freedom from forced labor"
label variable v2csgender  "Womens CSO participation"
label variable v2clprptyw  "Womens property rights"
label variable  v2clacjstw   "Womens access to justice"
label variable   v2cldiscw   "Freedom of discussion"
label variable   v2pepwrgen   "Power distributed by gender"
label variable   v2elfemrst   "Female suffrage"
 
set more off
*legislators
logit F.conflict_onset v2lgfemleg v2x_polyarchy v2x_polyarchy_sq s_far_Maddison_gdppc_1990_estim s_far_Maddison_pop_estimate peaceyears peaceyears2 peaceyears3 i.year i.region_best , cluster(country_id)
estimates store m1
*journalists
logit F.conflict_onset v2mefemjrn v2x_polyarchy v2x_polyarchy_sq s_far_Maddison_gdppc_1990_estim s_far_Maddison_pop_estimate peaceyears peaceyears2 peaceyears3 i.year i.region_best , cluster(country_id)
estimates store m2
*movement
logit F.conflict_onset v2cldmovew v2x_polyarchy v2x_polyarchy_sq s_far_Maddison_gdppc_1990_estim s_far_Maddison_pop_estimate peaceyears peaceyears2 peaceyears3 i.year i.region_best , cluster(country_id)
estimates store m3
*v2clslavef
logit F.conflict_onset v2clslavef v2x_polyarchy v2x_polyarchy_sq s_far_Maddison_gdppc_1990_estim s_far_Maddison_pop_estimate peaceyears peaceyears2 peaceyears3 i.year i.region_best , cluster(country_id)
estimates store m4
*v2csgender
logit F.conflict_onset v2csgender v2x_polyarchy v2x_polyarchy_sq s_far_Maddison_gdppc_1990_estim s_far_Maddison_pop_estimate peaceyears peaceyears2 peaceyears3 i.year i.region_best , cluster(country_id)
estimates store m5
*v2clprptyw
logit F.conflict_onset v2clprptyw v2x_polyarchy v2x_polyarchy_sq s_far_Maddison_gdppc_1990_estim s_far_Maddison_pop_estimate peaceyears peaceyears2 peaceyears3 i.year i.region_best , cluster(country_id)
estimates store m6
*v2clacjstw
logit F.conflict_onset v2clacjstw v2x_polyarchy v2x_polyarchy_sq s_far_Maddison_gdppc_1990_estim s_far_Maddison_pop_estimate peaceyears peaceyears2 peaceyears3 i.year i.region_best , cluster(country_id)
estimates store m7
*v2cldiscw
logit F.conflict_onset v2cldiscw v2x_polyarchy v2x_polyarchy_sq s_far_Maddison_gdppc_1990_estim s_far_Maddison_pop_estimate peaceyears peaceyears2 peaceyears3 i.year i.region_best , cluster(country_id)
estimates store m8
*v2pepwrgen
logit F.conflict_onset v2pepwrgen v2x_polyarchy v2x_polyarchy_sq s_far_Maddison_gdppc_1990_estim s_far_Maddison_pop_estimate peaceyears peaceyears2 peaceyears3 i.year i.region_best , cluster(country_id)
estimates store m9
*v2elfemrst
gen fem_suffr = .
replace fem_suffr=0
replace fem_suffr=1 if v2elfemrst==2
label variable  fem_suffr   "Female suffrage"
logit F.conflict_onset fem_suffr v2x_polyarchy v2x_polyarchy_sq s_far_Maddison_gdppc_1990_estim s_far_Maddison_pop_estimate peaceyears peaceyears2 peaceyears3 i.year i.region_best , cluster(country_id)
estimates store m10

esttab m1 m2 m3 m4 m5 m6 m7 m8 m9 m10 using "  " , style(tex) nogaps compress mtitles label stats(N countryFE regionFE roundFE districtFE homelandFE)

****************************************************************************************************************************************************
                                                        
														**TABLE 3 - CONTROLLING FOR VALUES
														**FIGURE 4 - INTERACTION
          
****************************************************************************************************************************************************

clear
use "imputationdata.dta", replace
 
 ****TAKING AVERAGES FROM THE IMPUTATIONS
 
 **Labeling the imputed measures
 label variable M_v2x_polyarchy "Democracy"
 label variable M_v2x_polyarchy_sq "Democracy^2"
 label variable M_lnpop "L(population)"
 label variable M_e_migdppcln "L(Gdp pc.)"
 label variable M_v2x_gender "FPE index"
 label variable M_v2x_gencl "Womens civil liberties"
 label variable M_v2x_gencs "Womens civil society participation"
 label variable M_v2x_genpp "Womens political participation"

 label variable M_men_work "Men more right to work"
 
 label variable M_men_leaders "Men make better political leaders" 
 
 label variable M_boys_uni "University more important for boys"
 
 label variable female_empow_values "Female empowerment values"
 

 ****::::::::::::::::::::CONTROLLING FOR SURVEY ITEMS::::::::::::::::::::::::::::***
 *Replicating baseline model controlling for gender equality values -- all variables imputed
 xtset gwno year
 set more off
 eststo clear
 
*gender index - year + region fe
logit conflict_onset M_v2x_gender M_v2x_polyarchy M_v2x_polyarchy_sq M_lnpop M_e_migdppcln peaceyears peaceyears2 peaceyears3 i.year i.e_region_world_2 , vce(robust)
estimates store m1 

*gender index - year + country fe
xtlogit conflict_onset M_v2x_gender M_v2x_polyarchy M_lnpop M_e_migdppcln peaceyears peaceyears2 peaceyears3 i.year , fe
estimates store m2 

*gender index - year + region fe
logit conflict_onset M_v2x_gender M_v2x_polyarchy M_v2x_polyarchy_sq M_lnpop M_e_migdppcln female_empow_values peaceyears peaceyears2 peaceyears3 i.year i.e_region_world_2 ,vce(robust)
estimates store m3 

*gender index - year + country fe
xtlogit conflict_onset M_v2x_gender M_v2x_polyarchy M_lnpop M_e_migdppcln female_empow_values peaceyears peaceyears2 peaceyears3 i.year , fe
estimates store m4

*TABLE 3
esttab m1 m2 m3 m4, replace style(tex) nogaps compress mtitles label stats(N N_g countryFE regionFE roundFE districtFE homelandFE)

***INTERACTION BETWEEN VALUES AND FPE
gen gen_int=M_v2x_gender*female_empow_values

logit conflict_onset M_v2x_gender  female_empow_values c.M_v2x_gender#c.female_empow_values M_v2x_polyarchy M_lnpop M_e_migdppcln peaceyears peaceyears2 peaceyears3 i.year i.e_region_world_2 , cluster(gwno)
estimates store m4

*FIGURE 4
margins, dydx(M_v2x_gender) at(female_empow_values=(1.18(.10)3.63))
marginsplot, yline(0) recast(line) recastci(rarea)
marginsplot, yline(0) recast(line) 

marginscontplot v2x_clpol v2xel_frefair, at1(0(0.1)1) at2(0(0.5)1) plotopts(scheme(sj)) show

summarize M_v2x_gender
summarize female_empow_values

quietly margins, at(M_v2x_gender=(-.06(.10).96) female_empow_values=(1.18(.10)3.63)) vce(unconditional) saving(predictions, replace)
use predictions, clear
rename _at1 M_v2x_gender
rename _at2  female_empow_values
twoway contour _margin M_v2x_gender female_empow_values


****************************************************************************************************************************************************
****************************************************************************************************************************************************

***************SENSITIVITY TO OBSERVABLES CHECKS
***************************************************************
clear
use "Basedata.dta"

xtset country_id time

gen gdp_far_maddison_growth = s_far_Maddison_gdppc_1990_estim-L.s_far_Maddison_gdppc_1990_estim
***LABELING
label variable v2x_gender "Womens empowerment index"
label variable v2x_gencl "Womens civil liberties"
label variable v2x_gencs "Womens civil society participation"
label variable v2x_genpp "Womens political participation"
label variable v2x_polyarchy "Democracy"
label variable v2x_polyarchy_sq "Democracy$^{2}$"
label variable e_migdppcln "GDP pc."
label variable lnpop "Population"
label variable v2lgfemleg  "Female legislators"
label variable  v2mefemjrn  "Female journalists"
label variable v2cldmovew  "Freedom of movement"
label variable  v2clslavef  "Freedom from forced labor"
label variable v2csgender  "Womens CSO participation"
label variable v2clprptyw  "Womens property rights"
label variable  v2clacjstw   "Womens access to justice"
label variable   v2cldiscw   "Freedom of discussion"
label variable   v2pepwrgen   "Power distributed by gender"
label variable   gdp_far_maddison_growth  "GDP pc. growth"

sort country_id year
merge 1:1 country_id year using "C:\Users\torewig_adm\Dropbox\V-Dem historical coding\CONTROL DATASET\DATASET\publicv8_ribbed_with_S_data.dta" , keepusing(e_peaveduc e_peinfmor e_miferrat e_pefeliex e_miurbani e_peginiwi )

*to keep the sample constant
regress conflict_onset hist_v2x_gender e_peinfmor e_miferrat e_pefeliex v2x_egaldem v2x_libdem v2x_partipdem v2x_delibdem  e_peaveduc e_miurbani e_peginiwi s_far_Maddison_gdppc_1990_estim s_far_Maddison_pop_estimate v2x_polyarchy v2x_polyarchy_sq peaceyears peaceyears2 peaceyears3 i.year i.region_best
estimates store a0


*BASELINE MODEL 
regress conflict_onset hist_v2x_gender  peaceyears peaceyears2 peaceyears3 i.year i.region_best if _est_a0==1, cluster(country_id)
estimates store a1

*INTRODUCING BASELINE CONTROLS
regress conflict_onset hist_v2x_gender s_far_Maddison_gdppc_1990_estim s_far_Maddison_pop_estimate v2x_polyarchy v2x_polyarchy_sq peaceyears peaceyears2 peaceyears3 i.year i.region_best if _est_a0==1, cluster(country_id)
estimates store a2

*INTRODUCING THE VDEM COMPONENTS
regress conflict_onset hist_v2x_gender v2x_egaldem v2x_libdem v2x_partipdem v2x_delibdem s_far_Maddison_gdppc_1990_estim s_far_Maddison_pop_estimate v2x_polyarchy v2x_polyarchy_sq peaceyears peaceyears2 peaceyears3 i.year i.region_best if _est_a0==1, cluster(country_id)
estimates store a3

*INTRODUCING FERTILITY AND INFANT MORTALITY AND FEMALE LIFE EXPECTANCY 
regress conflict_onset hist_v2x_gender e_peinfmor e_miferrat e_pefeliex  s_far_Maddison_gdppc_1990_estim s_far_Maddison_pop_estimate v2x_polyarchy v2x_polyarchy_sq peaceyears peaceyears2 peaceyears3 i.year i.region_best if _est_a0==1, cluster(country_id)
estimates store a4

*INTRODUCING inequality, urbanization etc.
regress conflict_onset hist_v2x_gender e_peaveduc e_miurbani e_peginiwi s_far_Maddison_gdppc_1990_estim s_far_Maddison_pop_estimate v2x_polyarchy v2x_polyarchy_sq peaceyears peaceyears2 peaceyears3 i.year i.region_best if _est_a0==1, cluster(country_id)
estimates store a5

*INTRODUCING FULL SET
regress conflict_onset hist_v2x_gender v2x_egaldem v2x_libdem v2x_partipdem v2x_delibdem e_peinfmor e_miferrat e_pefeliex e_peaveduc e_miurbani e_peginiwi s_far_Maddison_gdppc_1990_estim s_far_Maddison_pop_estimate v2x_polyarchy v2x_polyarchy_sq peaceyears peaceyears2 peaceyears3 i.year i.region_best if _est_a0==1, cluster(country_id)
estimates store a6

***CALCULATION
*baseline =  -.065
*with baseline controls (-.10/(-.065--.10) = 2.85
*with vdem controls (-.13/(-.065--.13)  = -2
*with fertility etc. (-.10/(-.065--.10) =  = -2.85
*with inequality etc. (-.12/(-.065--.12) =  = -2.18
*with full set (-.13/(-.065--.13)  = -2
label variable hist_v2x_gender "Womens empowerment index"
label variable v2x_gender "Womens empowerment index"
label variable v2x_gencl "Womens civil liberties"
label variable v2x_gencs "Womens civil society participation"
label variable v2x_genpp "Womens political participation"
label variable v2x_polyarchy "Democracy"
label variable v2x_polyarchy_sq "Democracy$^{2}$"
label variable e_migdppcln "GDP pc."
label variable lnpop "Population"
label variable v2lgfemleg  "Female legislators"
label variable  v2mefemjrn  "Female journalists"
label variable v2cldmovew  "Freedom of movement"
label variable  v2clslavef  "Freedom from forced labor"
label variable v2csgender  "Womens CSO participation"
label variable v2clprptyw  "Womens property rights"
label variable  v2clacjstw   "Womens access to justice"
label variable   v2cldiscw   "Freedom of discussion"
label variable   v2pepwrgen   "Power distributed by gender"
label variable   gdp_far_maddison_growth  "GDP pc. growth"
label variable v2x_egaldem "Egalitarian dem."
label variable v2x_libdem "liberal dem."
label variable v2x_partipdem "Participatory dem."
label variable v2x_delibdem "Deliberative dem."
label variable e_miferrat "Fertility rates"
label variable e_pefeliex "Female life exp."
label variable e_peaveduc "Education"
label variable e_peinfmor "Infant mortality"
label variable e_miurbani "urbanization"
label variable e_peginiwi "Inequality"
label variable s_far_Maddison_gdppc_1990_estim "GDP p.c."
label variable s_far_Maddison_pop_estimate "L(population)"


*Tables showing the sensitivity-calculation regression models, for table 7 in the appendix
esttab a1 a2 a3 a4 a5 a6 using " " , replace  style(tex) nogaps compress mtitles label stats(N countryFE regionFE roundFE districtFE homelandFE)
 




 
 
 
 
 
 